/*
	YoghurtGum - 2D Game Engine

	Copyright 2009-2011 Quinten Lansu
	
	Licensed under the Apache License, Version 2.0 (the "License"); you may not 
	use this file except in compliance with the License. You may obtain a copy 
	of the License at 
		
		http://www.apache.org/licenses/LICENSE-2.0 
		
	Unless required by applicable law or agreed to in writing, software 
	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
	License for the specific language governing permissions and limitations 
	under the License. 
*/

#ifndef _YGROOT_H_
#define _YGROOT_H_

#include "YGSettings.h"
#include "YGSources.h"
#include "YGWindow.h"
#include "YGRenderMethod.h"
#include "YGGame.h"

namespace YoghurtGum
{

	class Root;

	class YG_EXPORT Root
	{

		friend class Root;

	public:

		enum Property
		{
			PROP_WINDOWTITLE,
			PROP_RENDERER
		};

		static Root& GetSingleton();

		RenderMethod* GetRenderer();

		void SetProperty(Property a_Property, const char* a_Value);

		void InstallRenderer(const char* a_PluginName);

		void AttachGame(Game* a_Game);
		Game* GetGame();

		Scene* GetScene();

		bool Run();
		bool IsRunning();

		bool Init();
		void Resize(int a_Width, int a_Height);
		bool Start();
		bool Update();
		bool Render();
		void CloseDown();
		void Destroy();

		static void SetInstance(Root* a_Instance);

		Root();
		~Root();

	private:

		static Root*          s_Instance;

		bool                  m_Running;

		Window*               m_Window;
		RenderMethod*         m_Renderer;
		Game*                 m_Game;

		RenderMethod*         m_RendererOptions[8];
		uint32                m_RendererTotal;

		uint32                m_PhysicsStart, m_PhysicsCurrent;
		real                  m_PhysicsTime;

	}; // class Root

}; // namespace YoghurtGum

#endif